package com.example.demo.controller;

import cn.hutool.http.HttpRequest;
import com.example.demo.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/request")
@Slf4j
public class RequestController {

    @RequestMapping(value = "/aaa", method = RequestMethod.GET)

    public String method1() {
        //System.out.println("测试请求开始");
        String url = "http://is.snssdk.com/api/news/feed/v51/";
        String result = HttpRequest.get(url).timeout(3000).execute().body();
        if (result != null) {
            throw new BusinessException("code001", "firstException");
        }
        //System.out.println(result);

        return "aaa";
    }

    //测试正则用
    //public static void main(String[] args) {
    //    //String email1 = "dqwdq@example.com";
    //    //String email2 = "dqwdqw.dqw@example.couk";
    //    //String email3 = "baatbi.com@qq.com";
    //    //String email4 = "z.miao0253343434@atrs.dc.uk";
    //    //String email5 = "Johndeo.noreolk@verifone.com";
    //    //
    //    ////Pattern pattern = Pattern.compile("(?<!\\w|\\.|\\*|-)([\\w-],{1,3})[\\w-]*(@[\\w-]{1,63}(\\.[\\w-]{1,63}){1,2})");
    //    //Pattern pattern = Pattern.compile("([\\w-.]{1,63})[\\w-]*(@[\\w-]{1,63}(\\.[\\w-]{1,63}){1,2})");
    //    //Matcher matcher1 = pattern.matcher(email1);
    //    //Matcher matcher2 = pattern.matcher(email2);
    //    //Matcher matcher3 = pattern.matcher(email3);
    //    //Matcher matcher4 = pattern.matcher(email4);
    //    //Matcher matcher5 = pattern.matcher(email5);
    //    //
    //    //System.out.println("Email 1 is valid: " + matcher1.matches()); // 输出: Email 1 is valid: true
    //    //System.out.println("Email 2 is valid: " + matcher2.matches()); // 输出: Email 2 is valid: true
    //    //System.out.println("Email 3 is valid: " + matcher3.matches()); // 输出: Email 3 is valid: true
    //    //System.out.println("Email 4 is valid: " + matcher4.matches()); // 输出: Email 4 is valid: false
    //    //System.out.println("Email 5 is valid: " + matcher5.matches()); // 输出: Email 5 is valid: false
    //}
}
